/**
 * Created by Administrator on 2017/9/18.
 */

    $(function(){

        //搜索框里的数据
        $("#search").find("input").on("focus",function(){
            $(this).val("");
        })

        //全部商品列表悬停时出现下拉列表
        $("#nav>ul>li").eq(0).on("mouseenter",function(){
          $(this).children("ul").css("display","block")
        })
        //鼠标出去时列表消失
        $("#nav>ul>li").eq(0).on("mouseleave",function(){
            $(this).children("ul").css("display","none");
        })


        //全部商品列表里的三级列表
        $("#shop_list>li").on("mouseenter",function(){
            $(this).css("border","1px solid #ff5c00").css("color","#ff5c00").children("div").css("display","block").end().siblings().children("div").css("display","none");
        })
        $("#shop_list>li").on("mouseleave",function(){
            $(this).css("border","0").css("color","#888").children("div").css("display","none");
        })

        $("#shop_list").find("a").on("mouseenter",function(){
            $(this).css("color","#ff5c00");
        })
        $("#shop_list").find("a").on("mouseleave",function(){
            $(this).css("color","#888");
        })



        //右边栏用户部分
        $("#sc>i").on("mouseenter",function(){
            $(this).css("background-position","-22px 0px").siblings("div").css("opacity","1").css("left","-288px");
        })
        $("#sc>i").on("mouseleave",function(){
            $(this).css("background-position","0px 0px").siblings("div").css("opacity","0").css("left","-320px");
        })
        $("#close").on("click",function(){
            $(this).parent().parent().css("display","none");
        })

        //右边栏购物车部分
        $("#gouwu").on("mouseenter",function(){
            $(this).css("background-color","#ff5c00").children("i").css("background-position","-22px -22px");
        })
        $("#gouwu").on("mouseleave",function(){
            $(this).css("background-color","white").children("i").css("background-position","0px -22px");
        })

        //右边栏二维码部分
        $("#ewm").on("mouseenter",function(){
            $(this).css("background-color","#ff5c00").children("i").css("background-position","-22px -50px");
        })
        $("#ewm").on("mouseleave",function(){
            $(this).css("background-color","white").children("i").css("background-position","0px -50px");
        })

        //收藏部分
        $("#shoucang").on("mouseenter",function(){
            $(this).css("background-color","#ff5c00").children("i").css("background-position","-22px -75px");
        })
        $("#shoucang").on("mouseleave",function(){
            $(this).css("background-color","white").children("i").css("background-position","0px -75px");
        })

        //右边栏客服部分
        $("#kefu").on("mouseenter",function(){
            $(this).children("div").css("opacity","1").css("left","-83px");
        });
        $("#kefu").on("mouseleave",function(){
            $(this).children("div").css("left","-100px").css("opacity","0")
        })

        //右边栏客服部分
        $("#fanhui").on("mouseenter",function(){
            $(this).css("background-color","#ff5c00").children("i").css("background-position","-22px -129px").siblings().css("opacity","1");
        });
        $("#fanhui").on("mouseleave",function(){
            $(this).css("background-color","white").children("i").css("background-position","0px -129px").siblings().css("opacity","0");
        })



        var obj = {
            "url":"../json/homepage.json",
            "success":function(res){
                $(".tu").each(function(index,ele){
                    $(this).find("img").attr("src",res.tehui[index].img).end().find("h2").find("a").text(res.tehui[index].h2).end().end().find("span").text(res.tehui[index].span).end().find("b").text(res.tehui[index].price);
                })
            }
        }
        $.ajax(obj);


    })